package com.xsd.awen.web;

import com.xsd.awen.config.WebResult;
import com.xsd.awen.domain.entity.Task;
import com.xsd.awen.domain.vo.TaskVo;
import com.xsd.awen.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("task")
public class TaskController{

    @Autowired
    TaskService taskService;

    @PostMapping("page")
    public String page(TaskVo taskVo){
        return WebResult.page(taskService.page(taskVo));
    }

    @PostMapping("add")
    public String add(Task task){
        return taskService.save(task);
    }

    @PostMapping("update")
    public String update(Task task){
        return taskService.update(task);
    }

    @PostMapping("delete")
    public String delete(Task task){
        return taskService.delete(task);
    }

    @PostMapping("get")
    public String get(Task task){
        return WebResult.OK(taskService.getById(task.getId()));
    }

}